package com.example.clublesson01.login

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.SPUtils
import com.blankj.utilcode.util.ToastUtils
import com.bw.kf.lib_base.base.BaseActivity
import com.example.clublesson01.R
import com.example.clublesson01.databinding.ActivityChongBinding

@Route(path = "/app/login/ChongActivity")
class ChongActivity : BaseActivity<ActivityChongBinding,LoginRepo>() {

    @Autowired
    @JvmField
    var chongP:String=""

    override fun iniView() {
        ARouter.getInstance().inject(this)
        binding.ivBack.setOnClickListener {
            finish()
        }
        binding.btnOk.setOnClickListener {
            if(binding.password!=null){
                val CCOde = SPUtils.getInstance().getString("CCode")
                viewModel.BDCode(CCOde.toInt(),chongP,binding.password.text.toString())
            }
        }
    }

    override fun iniData() {
        viewModel.successBDCode.observe(this){
           if(it.code==200){
               ToastUtils.showShort("修改成功")
              ARouter.getInstance().build("/app/login/LoginActivity").navigation()
           }
        }

    }

    override fun getViewModel(): Class<LoginRepo> {
        return LoginRepo::class.java
    }
    override fun Layoutid(): Int {
        return R.layout.activity_chong
    }
}